<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends CommonController {

	
	//服务器设置
	public function setting(){
		$this->assign("main_title",L("setting"));
		$this->display();
	}
	
	public function top(){
		$this->display();
	}
	public function left(){
		$this->display();
	}
	public function index(){
		$oop=M("orderhistory");
		$con['oh_time']=array("like","%".date("Y-m-d")."%");
		//总交易数
		$data['total']=$oop->where($con)->count();
		//成功交易数
		$con1['oh_status']=array("in","2,4");
		$data['success_total']=$oop->where($con)->where($con1)->count();
		//成功交易额
		$data['success_total_amount']=$oop->where($con)->where($con1)->sum("oh_amount");
		//失败交易数
		$con1['oh_status']=array("in","5,6");
		$data['declined_total']=$oop->where($con)->where($con1)->count();
		//预授权
		$con1['oh_status']=3;
		$data['authorize_total']=$oop->where($con)->where($con1)->count();
		//退款
		$con1['oh_status']=array("in","7,8");
		$data['refund_total']=$oop->where($con)->where($con1)->count();		
		//拒付
		$con1['oh_status']=9;
		$data['cb_total']=$oop->where($con)->where($con1)->count();	
		
		//今日提现数
		$wd_con['wd_date']=$con['oh_time'];
		$data['today_withdraw']=M("withdraw")->where($wd_con)->count();
		//今日提现额
		$data['today_withdraw_amount']=M("withdraw")->where($wd_con)->sum("wd_amount");
		//提现总数
		$data['withdraw']=M("withdraw")->count();
		//未处理提现数
		$wd_con1['wd_status']=1;
		$data['pending_withdraw']=M("withdraw")->where($wd_con1)->count();
		
		//商户数
		$data['merchant']=M("merchant")->count();
		//网站数
		$data['site']=M("site")->count();
		//交易总数
		$data['order']=M("orders")->count();
		//代理商数
		$data['affiliate']=M("affiliate")->count();		
		//货运公司
		$data['tracking']=M('tracking')->count();
		//申请总数
		$data['application']=M("application")->count();
		//未处理申请
		$data['pending_application']=M("application")->where("app_status=1")->count();
		//代理商提现数
		$data['aff_withdraw']=M('affiliateWithdraw')->count();
		//代理商提现未处理数
		$data['aff_pending_withdraw']=M("affiliateWithdraw")->where("aw_status=1")->count();
		
		$this->assign($data);
		$this->display();
	}		
}